home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / tcl / xf2.3-p / xf2 / xf2.3 / elements / Text < prev    next >
Encoding:
Text File  |  1993-11-20  |  7.3 KB  |  232 lines

  1. # Program: xf
  2. # Description: handle text widgets
  3. #
  4. # $Header: Text[2.3] Wed Mar 10 11:59:19 1993 garfield@garfield frozen $
  5.  
  6. global xfDefaultConf
  7. set xfDefaultConf(text) 4
  8.  
  9. ##########
  10. # Procedure: XFAdd.Text
  11. # Description: add a text
  12. # Arguments: xfW - the widget
  13. #            xfName - a optional name
  14. #            xfType - add or config
  15. # Returns: none
  16. # Sideeffects: none
  17. ##########
  18. proc XFAdd.Text {xfW xfName xfType} {
  19.   global xfStatus
  20.  
  21.   XFEditSetStatus "Inserting Text..."
  22.   set xfName [XFMiscGetUniqueName $xfName text]
  23.   if {"$xfStatus(path)" == "."} {
  24.     if {"$xfType" == "add"} {
  25.       text .$xfName
  26.  
  27.       .$xfName insert 1.0 $xfName
  28.     } {
  29.       text .$xfName
  30.     }
  31.  
  32.     XFMiscPositionWidget .$xfName
  33.     XFMiscBindWidgetTree .$xfName
  34.   } {
  35.     if {"$xfType" == "add"} {
  36.       text $xfStatus(path).$xfName
  37.  
  38.       $xfStatus(path).$xfName insert 1.0 $xfName
  39.     } {
  40.       text $xfStatus(path).$xfName
  41.     }
  42.  
  43.     XFMiscPositionWidget $xfStatus(path).$xfName
  44.     XFMiscBindWidgetTree $xfStatus(path).$xfName
  45.   }
  46.  
  47.   incr xfStatus(elementCounter)
  48.   XFEditSetPath $xfStatus(path)
  49.   XFEditSetStatus "Inserting Text...done"
  50. }
  51.  
  52. ##########
  53. # Procedure: XFConfig.Text4
  54. # Description: configure a text
  55. # Arguments: xfW - the widget
  56. #            xfType - config type (add config)
  57. #            xfClass - the class we configure
  58. #            xfLeader - the leading window
  59. # Returns: none
  60. # Sideeffects: none
  61. ##########
  62. proc XFConfig.Text4 {xfW xfType xfClass {xfLeader ""}} {
  63.   global xfConf
  64.   global xfMisc
  65.   global xfStatus
  66.  
  67.   set xfMisc(wrap) none
  68.  
  69.   if {"$xfType" == "add"} {
  70.     set xfName text$xfStatus(elementCounter)
  71.   } {
  72.     set xfName [XFMiscPathName $xfW]
  73.   }
  74.   XFEditSetStatus "Calling parameter setting for Text..."
  75.  
  76.   # build widget structure
  77.   XFTmpltToplevel .xf${xfClass}Config4 400x500 \
  78.     "Text parameters:[XFMiscPathTail $xfW]" $xfLeader
  79.  
  80.   XFElementInit $xfW .xf${xfClass}Config4 $xfType $xfClass XFTextSetText4 \
  81.     parameters $xfName 4
  82.   XFElementColor $xfW .xf${xfClass}Config4 $xfType $xfClass bg \
  83.     background Background "Background" XFTextSetText4
  84.   XFElementScale $xfW .xf${xfClass}Config4 $xfType $xfClass borderwidth \
  85.     borderWidth BorderWidth "Border width" "pixels" 40 XFTextSetText4
  86.   XFElementBoolean $xfW .xf${xfClass}Config4 $xfType $xfClass exportSelection \
  87.     "Export selection" XFTextSetText4
  88.   XFElementFont $xfW .xf${xfClass}Config4 $xfType $xfClass font \
  89.     font Font "Font" XFTextSetText4
  90.   if {$xfConf(kanji)} {
  91.     XFElementFont $xfW .xf${xfClass}Config4 $xfType $xfClass kanjifont \
  92.       kanjiFont KanjiFont "Kanji font" XFTextSetText4
  93.   }
  94.   XFElementColor $xfW .xf${xfClass}Config4 $xfType $xfClass fg \
  95.     foreground Foreground "Foreground" XFTextSetText4
  96.   XFElementRelief $xfW .xf${xfClass}Config4 $xfType $xfClass XFTextSetText4
  97.   XFElementBoolean $xfW .xf${xfClass}Config4 $xfType $xfClass setGrid \
  98.     "Set grid" XFTextSetText4
  99.   XFElementSize $xfW .xf${xfClass}Config4 $xfType $xfClass XFTextSetText4
  100.  
  101.   XFTmpltFrame .xf${xfClass}Config4.params1.params2.frame2 0
  102.   
  103.   label .xf${xfClass}Config4.params1.params2.frame2.message1 \
  104.     -anchor e \
  105.     -width $xfStatus(elementWidth) \
  106.     -text "Wrap:"
  107.  
  108.   radiobutton .xf${xfClass}Config4.params1.params2.frame2.none \
  109.     -text "None" \
  110.     -variable xfMisc(wrap) \
  111.     -command "XFTextSetText4 $xfW 0 $xfClass"
  112.  
  113.   radiobutton .xf${xfClass}Config4.params1.params2.frame2.char \
  114.     -text "Char" \
  115.     -variable xfMisc(wrap) \
  116.     -command "XFTextSetText4 $xfW 0 $xfClass"
  117.  
  118.   radiobutton .xf${xfClass}Config4.params1.params2.frame2.word \
  119.     -text "Word" \
  120.     -variable xfMisc(wrap) \
  121.     -command "XFTextSetText4 $xfW 0 $xfClass"
  122.  
  123.   pack append .xf${xfClass}Config4.params1.params2.frame2 \
  124.               .xf${xfClass}Config4.params1.params2.frame2.message1 {left} \
  125.               .xf${xfClass}Config4.params1.params2.frame2.none {left} \
  126.               .xf${xfClass}Config4.params1.params2.frame2.char {left} \
  127.               .xf${xfClass}Config4.params1.params2.frame2.word {left}
  128.   pack append .xf${xfClass}Config4.params1.params2 \
  129.               .xf${xfClass}Config4.params1.params2.frame2 {top fillx}
  130.  
  131.   XFElementText $xfW .xf${xfClass}Config4 $xfType $xfClass yscrollcommand \
  132.     yscrollcommand YScrollCommand "Y scroll command" XFTextSetText4
  133.  
  134.   if {"$xfType" != "add"} {
  135.     case [lindex [$xfW config -wrap] 4] in {
  136.       {none} {
  137.         .xf${xfClass}Config4.params1.params2.frame2.none select
  138.       }
  139.       {char} {
  140.         .xf${xfClass}Config4.params1.params2.frame2.char select
  141.       }
  142.       {default} {
  143.         .xf${xfClass}Config4.params1.params2.frame2.word select
  144.       }
  145.     }
  146.   }
  147.  
  148.   # save current parameter
  149.   if {$xfConf(kanji)} {
  150.     XFElementSave $xfW $xfClass {background borderwidth exportselection font kanjifont foreground height relief setgrid width wrap yscrollcommand}
  151.   } {
  152.     XFElementSave $xfW $xfClass {background borderwidth exportselection font foreground height relief setgrid width wrap yscrollcommand}
  153.   }
  154.  
  155.   # packing
  156.   pack append .xf${xfClass}Config4.params1 \
  157.               .xf${xfClass}Config4.params1.params2 {left fill expand}
  158.   pack append .xf${xfClass}Config4 \
  159.               .xf${xfClass}Config4.pathname {top fill frame center} \
  160.               .xf${xfClass}Config4.leave {bottom fill} \
  161.               .xf${xfClass}Config4.additional {bottom fill} \
  162.               .xf${xfClass}Config4.params1 {top fill expand}
  163.  
  164.   XFBindFormConnect .xf${xfClass}Config4.params1.params2 \
  165.     "XFTextSetText4 $xfW 0 $xfClass"
  166.  
  167.   XFEditSetStatus "Calling parameter setting for Text...done"
  168. }
  169.  
  170. ##########
  171. # Procedure: XFSaveSpecial.Text
  172. # Description: save text
  173. # Arguments: xfW - the widget
  174. # Returns: none
  175. # Sideeffects: none
  176. ##########
  177. proc XFSaveSpecial.Text {xfW} {
  178.  
  179.   return "  $xfW insert end \{[XFMiscGetText $xfW]\}\n"
  180. }
  181.  
  182. ##########
  183. # Procedure: XFTextSetText4
  184. # Description: set text parameters
  185. # Arguments: xfW - the widget
  186. #            xfType - the type of setting (1 = set always, 0 = set
  187. #                     only if permanent apply is on)
  188. #            xfClass - the class we configure
  189. #            xfParam1 - ignored parameter
  190. # Returns: none
  191. # Sideeffects: none
  192. ##########
  193. proc XFTextSetText4 {xfW xfType xfClass {xfParam1 ""}} {
  194.   global xfConf
  195.   global xfMisc
  196.  
  197.   if {$xfType == 0 && !$xfConf(applyParameters)} {
  198.     return
  199.   }
  200.   if {"[info commands $xfW]" == ""} {
  201.     return
  202.   }
  203.   XFMiscSetSymbolicName $xfW \
  204.     [.xf${xfClass}Config4.params1.params2.symname.symname get]
  205.  
  206.   XFMiscSetResource $xfW background \
  207.     [.xf${xfClass}Config4.params1.params2.bg.bg get]
  208.   XFMiscSetResource $xfW borderwidth \
  209.     [.xf${xfClass}Config4.params1.params2.borderwidth.borderwidth get]
  210.   XFMiscSetResource $xfW exportselection $xfMisc(exportSelection)
  211.   XFMiscSetResource $xfW font \
  212.     [.xf${xfClass}Config4.params1.params2.font.font get]
  213.   if {$xfConf(kanji)} {
  214.     XFMiscSetResource $xfW kanjifont \
  215.       [.xf${xfClass}Config4.params1.params2.kanjifont.kanjifont get]
  216.   }
  217.   XFMiscSetResource $xfW foreground \
  218.     [.xf${xfClass}Config4.params1.params2.fg.fg get]
  219.   XFMiscSetResource $xfW height \
  220.     [.xf${xfClass}Config4.params1.params2.size.size2.size2 get]
  221.   XFMiscSetResource $xfW relief $xfMisc(relief)
  222.   XFMiscSetResource $xfW setgrid $xfMisc(setGrid)
  223.   XFMiscSetResource $xfW width \
  224.     [.xf${xfClass}Config4.params1.params2.size.size1.size1 get]
  225.   XFMiscSetResource $xfW wrap $xfMisc(wrap)
  226.   XFMiscSetResource $xfW yscrollcommand \
  227.     [.xf${xfClass}Config4.params1.params2.yscrollcommand.yscrollcommand get]
  228. }
  229.  
  230. # eof
  231.  
  232.